<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="船只编号" prop="boatCode">
        <el-input
          v-model="queryParams.boatCode"
          placeholder="请输入船只编号"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          unlink-panels
          :default-time="['00:00:00', '23:59:59']"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" style="margin-bottom: 5px"></right-toolbar>

    <el-table v-loading="loading" :data="operationStatusList">
      <el-table-column label="序号" type="index" width="80" align="center"></el-table-column>
      <el-table-column label="所属景区" prop="scenicShortName" width="120" align="center"/>
      <el-table-column label="船只编号" prop="boatCode" width="90" align="center"/>
      <el-table-column label="内容" prop="content" align="center"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="250">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {selectScenicOperationDynamicInfoListByPage} from "@/api/system/scenicOperationDynamicInfo"
import store from "@/store";

export default {
  name: "OperationStatus",
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        boatCode: "", //船只编号
      },
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 遮罩层
      loading: true,
      // 日期范围
      dateRange: [],
      // 运营动态表格数据
      operationStatusList: [],
      scenicId: undefined, //景区id

    }
  },
  mounted() {
    this.scenicId = store.getters.scenicId;

    if (this.scenicId) {
      this.getList();
    } else {
      this.$modal.msgError("景区id为空，获取景区运营动态列表失败！");
    }
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getList() {
      if (this.scenicId) {
        this.loading = true;
        this.queryParams.scenicId = this.scenicId;
        selectScenicOperationDynamicInfoListByPage(this.queryParams).then(res => {
          console.log("selectScenicOperationDynamicInfoListByPage res: ", res)
          this.operationStatusList = res.rows;
          this.total = res.total;
          this.loading = false;
        })
      } else {
        this.$modal.msgError("景区id为空，获取景区运营动态列表失败！");
      }


    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
}
</script>

<style scoped>

</style>
